#include "stdafx.h"
#include "win_tabbar.h"
#pragma comment(lib,"comctl32.lib")

win_tabbar::win_tabbar()
{
    _dwExStyle = WS_EX_PALETTEWINDOW;
    _dwStyle = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE | TCS_TOOLTIPS | TCS_FOCUSNEVER | TCS_TABS;
}


win_tabbar::~win_tabbar()
{
}

bool win_tabbar::reg_class(HINSTANCE hInstance, PTCHAR pszClassName)
{
    if(hInstance)
    {
        _hInstance = hInstance;   
    }
    else if(NULL == _hInstance)
    {
        _hInstance = GetModuleHandle(NULL);
    }

    _tcscpy_s(_szClassName, WC_TABCONTROL);

    INITCOMMONCONTROLSEX icex;
	icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
	icex.dwICC  = ICC_TAB_CLASSES;
	if(TRUE == InitCommonControlsEx(&icex))
    {
        return 1;
    }

    return 0;
}

LRESULT win_tabbar::add_button(LPTSTR szTabName, const int nPos)
{
	TCITEM tie; 
	tie.mask = TCIF_TEXT | TCIF_IMAGE;
	int index = -1;

    /*
	if (_hasImgLst)
		index = 0;
    */

	tie.iImage = index; 
	tie.pszText = szTabName; 
	return ::SendMessage(_hWnd, TCM_INSERTITEM, nPos, reinterpret_cast<LPARAM>(&tie));
}
